package facade;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import entidad.TipoHabitacion;

/**
 * Session Bean implementation class TipoHabitacionFacade
 */
@Stateless
@LocalBean
public class TipoHabitacionFacade implements TipoHabitacionFacadeRemote {
	
	@PersistenceContext(unitName = "sgh001EJB")
    private EntityManager em;
    /**
     * Default constructor. 
     */
    public TipoHabitacionFacade() {
        // TODO Auto-generated constructor stub
    }
    
    @Override
    public List<TipoHabitacion> listar() {
    	Query query = em.createQuery("select t from tipo_habitacion t");
    	@SuppressWarnings("unchecked")
    	List<TipoHabitacion> result = query.getResultList();
    	return result;
    }
    
    @Override
    public void save(TipoHabitacion tipoHabitacion) {
    	em.persist(tipoHabitacion);
    }
    
    @Override
    public void edit(TipoHabitacion tipoHabitacion) {
    	em.merge(tipoHabitacion);
    }
    
    @Override
    public void remove(TipoHabitacion tipoHabitacion) {
    	em.remove(tipoHabitacion);
    }
}
